Skip to content

Avoid double formatting in mo.output.replace#9909

Open
lxingy3 wants to merge 1 commit into
marimo-team:mainfrom
lxingy3:fix-output-replace-single-format
Open

Avoid double formatting in mo.output.replace#9909
lxingy3 wants to merge 1 commit into
marimo-team:mainfrom
lxingy3:fix-output-replace-single-format

Conversation

@lxingy3

@lxingy3 lxingy3 commented Jun 17, 2026

Copy link
Copy Markdown

Summary

Closes #9681

mo.output.replace(value) was formatting value once for the imperative output list and then again when broadcasting the cell output. This reuses the Html object produced for the output list when sending the notification, so expensive _repr_html_ / __panel__ paths only run once.

A regression test covers a probe object whose _repr_html_ increments a counter.

Tests

  • python -m pytest tests\_runtime\output\test_output.py -q
  • python -m ruff check marimo\_runtime\output\_output.py tests\_runtime\output\test_output.py
  • git diff --check

Review in cubic

@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jun 25, 2026 6:32am

Request Review

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@lxingy3

lxingy3 commented Jun 25, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@lxingy3 lxingy3 force-pushed the fix-output-replace-single-format branch from 95e3db8 to ff3d9f8 Compare June 25, 2026 06:32
@lxingy3 lxingy3 marked this pull request as ready for review June 25, 2026 06:36
@lxingy3

lxingy3 commented Jun 25, 2026

Copy link
Copy Markdown
Author

Rebased this on current main to pick up the auth test/dependency fix that was already green upstream.

Local checks:

uv run --group test pytest tests/_runtime/output/test_output.py tests/_server/api/test_auth.py -q
uv run --group dev ruff check marimo/_runtime/output/_output.py tests/_runtime/output/test_output.py tests/_server/api/test_auth.py

The PR diff is still limited to the output replacement fix and its regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mo.output.replace(value) calls formatting.as_html(value) twice, doubling cost for expensive __panel__ / _repr_html_

2 participants